package org.steven.crm.core.exception;

import com.steven.common.errors.StandardErrors;

/**
 * @Author wuzw
 * @Date 2021/7/3 10:12
 * @Version 1.0
 */
public class ServiceException extends RuntimeException {
    private String code;
    private String message;

    public ServiceException(Throwable cause) {
        super(cause);
        this.code = StandardErrors.UNKNOWN.getCode();
        this.message = cause.getMessage();
    }

    public ServiceException(String message) {
        super();
        this.code = StandardErrors.UNKNOWN.getCode();
        this.message = message;
    }

    public ServiceException(String code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    public ServiceException(StandardErrors.ServerError errors) {
        super();
        this.code = errors.getCode();
        this.message = errors.getMessage();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
